program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  arr=array of integer;
var
  mass: array of arr;
  n, i, j, flag: integer;
  fin, fout: textfile;
begin
  flag:=0;
  assignfile(fin, 'input.txt');
  reset(fin);
  assignfile(fout, 'output.txt');
  rewrite(fout);
  readln(fin, n);
  setlength(mass, n);
  for i:=0 to n-1 do
    setlength(mass[i], n);
  for i:=0 to n-1 do
    for j:=0 to n-1 do
      read(fin, mass[i,j]);
  for i:=0 to n-1 do
    if (mass[i,i]=1) then
    begin
      flag:=1;
      break;
    end;
  if (flag=0) then
  begin
    flag:=0;
    for i:=0 to n-1 do
      for j:= i to n-1 do
        if (mass[i,j]<>mass[j,i]) then
        begin
          flag:=1;
          break;
        end;
    if (flag=0) then
    begin
      writeln(fout, 'YES');
    end else begin
      writeln(fout, 'NO');
    end;
  end else begin
    writeln(fout, 'NO');
  end;
  closefile(fin);
  closefile(fout);
end.
 